package com.ny.demo.demo523;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class TestConnection {
    private static final String URL ="jdbc:mysql://localhost:3306/usersdb";
    private  static final String USERNAME ="root";
    private  static final String USERPASSWORD="123456";
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
       Class.forName("com.mysql.cj.jdbc.Driver");
        Connection connection = DriverManager.getConnection(URL,USERNAME,USERPASSWORD);
        String sql ="INSERT INTO users(usersname,password) VALUES('1', '1')";
        PreparedStatement preparedStatement=connection.prepareStatement(sql);
        int i =preparedStatement.executeUpdate();
        if (i>0) {
            System.out.println("注册成功");
        }
        else {
            System.out.println("注册失败");
        }
    }
}
